package com.mdd.front.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Assert;
import com.mdd.common.entity.Proposal;
import com.mdd.common.mapper.ProposalMapper;
import com.mdd.common.util.TimeUtils;
import com.mdd.front.LikeFrontThreadLocal;
import com.mdd.front.service.IProposalService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 建议反馈服务
 * @author shenjian
 * @createTime 2023年03月04日 11:20:00
 */
@Service
public class ProposalServiceImpl implements IProposalService {

    @Resource
    ProposalMapper proposalMapper;

    @Override
    public int add(String content) {
        Integer userId = LikeFrontThreadLocal.getUserId();
        Assert.notEmpty(content, "请填写建议和意见");
        Proposal proposal = new Proposal();
        proposal.setUserId(userId);
        proposal.setContent(content);
        proposal.setStatus(0);
        proposal.setCreateTime(TimeUtils.timestamp());
        return proposalMapper.insert(proposal);
    }
}
